<?php
// +----------------------------------------------------------------------------
// | Tke团队版权所属 [三十年河东三十年河西,莫欺少年穷.!]
// +----------------------------------------------------------------------------
// | Copyright (c) 2014 http://www.itdaodan.com All rights reserved.
// +----------------------------------------------------------------------------
// | Author: fzh<fanzhaohai@hrbjjhh.com>
// +----------------------------------------------------------------------------

namespace Admin\Model;
use Admin\Model\BaseModel;
/**
 * 客户信息模型
 */
class ServiceExpressDetailModel extends BaseModel {

    /* 自动验证规则 */
    protected $_validate = array(
        array('receiving_address', '1,100', '地址长度不能超过100个字符', self::VALUE_VALIDATE, 'length', self::MODEL_BOTH),
        array('receiving_user', '1,6', '收件人长度不能超过6个字符', self::VALUE_VALIDATE, 'length', self::MODEL_BOTH),
        array('receiving_phone_number', '1,20', '手机号码长度不能超过20个字符', self::VALUE_VALIDATE, 'length', self::MODEL_BOTH),
        array('express_id', 'number', '请正确的选择快递公司', self::VALUE_VALIDATE, '', self::MODEL_BOTH),
        array('express_id', array(0), '请选择快递公司', self::VALUE_VALIDATE, 'notin', self::MODEL_BOTH),
        array('courier_number', 'courier_number', '快递单号格式错误，必须是数字和字母', self::VALUE_VALIDATE, 'callback', self::MODEL_BOTH),
        array('courier_number', '1,15', '快递单号长度不能超过15个字符', self::VALUE_VALIDATE, 'length', self::MODEL_BOTH),
        array('mail_status', array(0,1,2,3), '请选择快递状态', self::VALUE_VALIDATE, 'in', self::MODEL_BOTH),

    );

    /* 自动完成规则 */
    protected $_auto = array(
//         array('receiving_address', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('receiving_user', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('receiving_phone_number', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('express_id', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//        array('courier_number', 'int', self::MODEL_BOTH, 'function'),
        array('mail_time', 'time', self::MODEL_BOTH, 'function'),
    );
    
    function courier_number($param){
        if(!preg_match("/^[a-z\d]*$/i", $param)){
            return false;
        }else{
            return true;
        }
    }

    /**
     * @todo 返回主键
     * @see \Think\Model::getPk()
     */
    public function getPk(){
        return 'express_detail_id';
    }
}